﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using LinFu.IoC.Configuration;
using LinFu.Proxy.Interfaces;
using LinFu.Reflection.Emit;
using Mono.Cecil;
using Mono.Cecil.Cil;

namespace CoreEx.Common.Tests
{
    [Implements(typeof(IMethodBodyEmitter),ServiceName = "ISerializable")]
    public class SampleSerializeableEmitter : IMethodBodyEmitter
    {
        public SampleSerializeableEmitter(TypeDefinition typeDefinition)
        {
        }

        public void Emit(MethodInfo originalMethod, MethodDefinition targetMethod)
        {
            var IL = targetMethod.GetILGenerator();

            var exceptionCtor = targetMethod.DeclaringType.Module.ImportConstructor<NotImplementedException>();
            IL.Emit(OpCodes.Newobj, exceptionCtor);
            IL.Emit(OpCodes.Throw);
        }
    }
}
